<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-3.3.1.min.js"></script>
    <style>

    </style>
</head>
<body>
<div id="box">
    <button id="buy">立即抢购</button>
</div>
<script>
    let url = "ws:localhost:8080/WebsocketController/zhangsan"
    var ws = new WebSocket(url);

        //3.2
        ws.onmessage = function (result) {
            let message = JSON.parse(result.data).message;
            console.log(message);
            alert(message)
        }
        //发送消息
        $("#buy").click(function(){
            $.ajax({
                url:"/kill?account=zhangsan",
                success:function (result) {
                    console.log(result)
                }
            })
        });
</script>
</body>
</html>